package com.breaktian.demoapp.toobar;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.breaktian.demoapp.R;

/**
 * Created by Administrator on 2017/1/15.
 */

public class TooBarFragmentBuilder {

    private String title;
    private View view;
    private int rightIcon;
    private View.OnClickListener rightClickListener;
    private boolean hasDownImg;
    private Context context;

    /**
     * 标题
     * */
    public TooBarFragmentBuilder setTitle(String title){
        this.title = title;
        return this;
    }

    public TooBarFragmentBuilder setHasDownImg(boolean hasDownImg, Context context) {
        this.hasDownImg = hasDownImg;
        this.context = context;
        return this;
    }

    /**
     * 右边图标
     * */
    public TooBarFragmentBuilder setRightIcon(int rightIcon){
        this.rightIcon = rightIcon;
        return this;
    }

    public TooBarFragmentBuilder setRightClickListener(View.OnClickListener listener){
        this.rightClickListener = listener;
        return this;
    }




    public TooBarFragmentBuilder build(View view){
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        if(!TextUtils.isEmpty(title)){
            tv_title.setText(title);
        }

        view.findViewById(R.id.iv_sao).setOnClickListener(rightClickListener);

        return this;
    }


}
